package com.qf.service.impl;

import com.qf.dao.UserDao;
import com.qf.entity.User;
import com.qf.service.UserService;
import com.qf.utils.ErrorCode;
import com.qf.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author zdl
 * @date 2025/2/7
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;
    @Override
    public void findUser() {
        System.out.println("这是service层的findUser方法");
    }

    @Override
    public void delUser() {
        System.out.println("这是service层的delUser方法");
    }

    @Override
    public User login(User user) {
        User user1 = loginUser(user);
        if (user1 == null){
            ResultUtils.error(ErrorCode.USER_NAME_PASSWORD_ERROR);
        }
        return user1;
    }
    public User loginUser(User user){
        System.out.println(user.getUsername()+"----->"+user.getPassword());
        return userDao.selectUserByUser(user);
    }
}
